﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Collections;
namespace WindowsGame4
{
    public class RayGun : Weapon
    {
        public RayBlast ray;
        public RayGun(Player owner)
            : base(owner)
        {
            ray = new RayBlast();
            ray.bOntimer = false;
            ray.bDieOnHit = false;
            ray.hit = Projectile.HitType.Enemy;
            ray.damage = damage = 5;
        }
        public override void BeginFire(Vector2 target)
        {
            ray.bDead = false;
            GameManager.objects.Add(ray);
            base.BeginFire(target);
        }
        public override void Fire(Vector2 target)
        {
            Vector2 dir = target - player.pos;
            if (dir.Length() > 0)
                dir.Normalize();
            ray.pos = player.pos + dir * (ray.GetRadius() + player.GetRadius());
            ray.angle = angle + 180;
            base.Fire(target);
            GameManager.shootRay.Play();
        }
        public override float GetRayWidth()
        {
            return base.GetRayWidth()*.01f;
        }
        public override void EndFire(Vector2 target)
        {
            ray.bDead = true;
            base.EndFire(target);
        }
        public override void OnDeath()
        {
            base.OnDeath();
            ray.bDead = true;
        }
        public override void SetLevel(int level)
        {
            ray.damage = damage * (level+1);
            ray.scale.Y = .5f + (float)level / (float)2;
            base.SetLevel(level);
        }
    }
}
